package com.yuge.xiaohua.api

import com.squareup.okhttp.OkHttpClient

import retrofit.GsonConverterFactory
import retrofit.Retrofit

/**
 * Created by Mrper on 15-12-12.
 */
class ApiManager private constructor() {

    private val httpApi: HttpApi

    init {
        val okHttpClient = OkHttpClient()
        val retrofit = Retrofit.Builder().baseUrl(BaseUrl).client(okHttpClient).addConverterFactory(GsonConverterFactory.create()).build()
        httpApi = retrofit.create(HttpApi::class.java)
    }

    companion object {

        val BaseUrl = "http://api.1-blog.com/"

        private var apiManager: ApiManager? = null

        fun getHttpApi(): HttpApi {
            if (apiManager == null)
                apiManager = ApiManager()
            return apiManager!!.httpApi
        }
    }

}
